package com.ff.miaosha.util;

import org.apache.commons.codec.digest.DigestUtils;

public class MD5Util {

    public static final String salt="1a2b3c4d";

    public static String md5(String src){
        return DigestUtils.md5Hex(src);
    }

    public static String inputPasswordToFormPass(String inputPass){
        String str=""+salt.charAt(0)+salt.charAt(2)+inputPass+salt.charAt(5)+salt.charAt(4);
        System.out.println(str);
        return md5(str);
    }

    public static String formpassToDBPass(String formPass,String salt){
        String str=""+salt.charAt(0)+salt.charAt(2)+formPass+salt.charAt(5)+salt.charAt(4);
        return md5(str);
    }

    public static String inputPassToDbPass(String inputPass,String saltDB){
        String formPass=inputPasswordToFormPass(inputPass);
        String dbPass=formpassToDBPass(formPass,saltDB);
        return dbPass;
    }


    public static void main(String[] args){
       String result= inputPassToDbPass("123456",salt);
        System.out.println("result=="+result);
    }

}
